package com.liuwei.assemble.config;

/**
 * @author : evan.liu
 * @version V1.0
 * @Description: TODO
 * @date Date : 2022年05月01日 3:31 上午
 */

import com.liuwei.assemble.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler
    public Result exceptionHandler(HttpServletRequest req, Exception e) throws Exception {
        log.error("GlobalException|error:{}",e.getMessage(),e);
        return Result.fail(e.getMessage());
    }
}

